#include <gvl/test/test.hpp>

#include <cstdio>

#include "../../psync5/node.hpp"

using namespace Psync5;

GVLTEST_SUITE(psync, connection)

GVLTEST(psync, connection, connect)
{
	Node server, client;

	gvl::init_sockets();

	server.host(1337);
	client.connect("localhost", 1337);

	uint32_t start = gvl::get_ticks();

	
	while(!client.serverLink()->connected())
	{
		server.process();
		client.process();

		if((gvl::get_ticks() - start) > 1000)
		{
			ASSERT("connection timed out", false);
			break;
		}
	}

	#if 0
	while(true)
	{
		server.process();
		client.process();
	}
	#endif
}
